class Solution
{
public:
    unordered_map<char, int>hash; //记录字符出现的次数
    queue<char>q;
  //Insert one char from stringstream
    void Insert(char ch) {
         hash[ch]++;
        q.push(ch);
    }
  //return the first appearence once char in current stringstream
    //如果队头为次数为1，直接输出
    //如果不为1，出队
    //如果队列为空.#
    char FirstAppearingOnce() {
        while(!q.empty()&&hash[q.front()]!=1)
            q.pop();
        if(q.empty())
            return '#';
        return q.front();
    }

};